import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:industry_net/base/common/colors_util.dart';
import 'package:industry_net/base/common/icon_util.dart';
import 'package:industry_net/base/common/img_util.dart';
import 'package:industry_net/base/common/route/routes.dart';
import 'package:industry_net/base/common/size_fit.dart';
import 'package:industry_net/base/common/text_util.dart';
import 'package:industry_net/base/component/component.dart';
import 'package:industry_net/pages/me/main/controller.dart';

part 'me_info.dart';
part 'usually_fuc.dart';
part 'header_order.dart';
part 'wallert.dart';

// SliverPersistentHeader buildHeader() {
//   return SliverPersistentHeader(
//     delegate: MeHeaderDelegate(),
//     pinned: true,
//   );
// }

SliverList buildHeader() {
  return SliverList(
    delegate: SliverChildListDelegate([const MeHeader()]),
  );
}

class MeHeader extends StatelessWidget {
  const MeHeader({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 503.w,
      child: Stack(
        children: [
          Positioned(
              width: Get.width,
              height: 247.5.w,
              child: loadImage(url: 'bj_head.png'.imgPathMe)),
          Positioned(
              top: 110.w,
              child: Column(
                children: [
                  UsuallyView(),
                  OrderStateView(),
                  MyWallertView(),
                  Row(
                    children: [
                      loadImage(
                          url: 'pic_Textdecoration.png'.imgPathMe,
                          width: 25.w,
                          fit: BoxFit.contain),
                      SizedBox(
                        width: 10.w,
                      ),
                      Text(
                        '猜你喜欢',
                        style: pfSCStyle(
                            color: ColorsUtil.title, fontSize: font17),
                      ),
                      SizedBox(
                        width: 10.w,
                      ),
                      Transform.rotate(
                        angle: pi,
                        child: loadImage(
                            url: 'pic_Textdecoration.png'.imgPathMe,
                            width: 25.w,
                            fit: BoxFit.contain),
                      )
                    ],
                  )
                ],
              ))
        ],
      ),
    );
  }
}

class MeHeaderDelegate extends SliverPersistentHeaderDelegate {
  @override
  Widget build(
      BuildContext context, double shrinkOffset, bool overlapsContent) {
    return const MeHeader();
  }

  @override
  double get maxExtent => 503.w;

  @override
  double get minExtent => 110.5.w;

  @override
  bool shouldRebuild(covariant SliverPersistentHeaderDelegate oldDelegate) {
    return true;
  }
}
